﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebNormal
{
    public partial class UsePaging : System.Web.UI.Page
    {
        protected int curIndex = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setAspPagerStyle(apg1);
                ViewState["strWhere"] = " 1=1";
                ProcessPaging();
            }
        }

        /// <summary>
        /// 银行分页
        /// </summary>
        /// <summary>
        private void ProcessPaging()
        {
            
            MO_easyPages mo_page = new MO_easyPages();
            string strWhere = ViewState["strWhere"].ToString();

            if (strWhere != "" && strWhere != null)
            {
                mo_page.Condition = strWhere;
            }

            int V_pageSize = this.apg1.PageSize;
            int V_page = this.apg1.CurrentPageIndex;

            mo_page.TableName = "VI_AccountAndBank";
            mo_page.Fields = "*";
            mo_page.OrderExpression = " BankName asc,AccountAb asc";
            mo_page.PageSize = V_pageSize;
            mo_page.PageIndex = V_page;

            DataTable dt = Tools.Tool.GetPagesEasy(mo_page);
            rptAccount.DataSource = dt;
            rptAccount.DataBind();

            apg1.RecordCount = mo_page.Count;
        }
        protected void apg1_PageChanged(object sender, EventArgs e)
        {
            ProcessPaging();
        }


        /// <summary>
        /// 设计分页样式.此方法应放入一个公共类当中,以便统一设定样式.
        /// </summary>
        /// <param name="page1"></param>
        public static void setAspPagerStyle(Wuqi.Webdiyer.AspNetPager page1)
        {
            page1.CssClass = "anpager";
            page1.ShowCustomInfoSection = Wuqi.Webdiyer.ShowCustomInfoSection.Left;
            page1.CustomInfoHTML = "总共%RecordCount%，当前第 %CurrentPageIndex% / %PageCount%，每页%PageSize%条";
            page1.CurrentPageButtonClass = "cpb";
            page1.CurrentPageButtonStyle = "";
            page1.AlwaysShow = false;
        }



    }
}
